#ifndef KD_TREE
#define KD_TREE

#include "KDNode.h"
#include "WorldObject.h"
#include "Player.h"
#include <stdio.h>
#include "TreeBuilder.h"


class KDTree {
	public:
		KDTree(float xdim, float ydim, float zdim, Player *p, Location l);
		~KDTree(void);
		void addObject(WorldObject* toAdd);
		void removeObject(WorldObject* toRemove);
		std::list<WorldObject *> toDraw(void);
		KDNode getNode();
		void printTree();
		void unload();
		Player* getPlayer();
		void update();
	private:
		void printTreeRecur(KDNode *node);
		KDNode *root;
		Player *play;
		void freeNode(KDNode *node);
		void unloadRecur(KDNode *node);
		int getAxis();
		FILE* fp;

};

#endif //KD_TREE